perm filename F7[CLS,LSP] blob
sn#871207 filedate 1989-03-17 generic text, type C, neo UTF8
COMMENT ā VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 %Start Part 7 of 8 functi.tex
C00025 ENDMK
Cā;
%Start Part 7 of 8 functi.tex
\label Syntax:
\Defgen {remove-method} {generic-function method}
\label Method Signatures:
\Defmeth {remove-method} {\vtop{\hbox{({\it generic-function\/} standard-generic-function)}
\hbox{\it method}}}
\label Arguments:
The {\it generic-function\/} argument is a generic function
object.
The {\it method\/} argument is a method object. The function {\bf
remove-method} does not signal an error if the method is not one of the
methods on the generic function.
\label Values:
The modified generic function is returned. The result of {\bf remove-method}
is {\bf eq} to the {\it generic-function\/} argument.
\label See Also:
{\bf find-method}
\endcom
\begincom{shared-initialize}\ftype{Standard Generic Function}
\label Purpose:
The generic function {\bf shared-initialize} is used to fill the slots
of an instance using initialization arguments and {\bf :initform}
forms. It is called when an instance is created, when an instance is
re-initialized, when an instance is updated to conform to a redefined
class, and when an instance is updated to conform to a different
class. The generic function {\bf shared-initialize} is called by the
system-supplied primary method for {\bf initialize-instance}, {\bf
reinitialize-instance}, {\bf update-instance-for-redefined-class}, and
{\bf update-instance-for-different-class}.
The generic function {\bf shared-initialize} takes the following
arguments: the instance to be initialized, a specification of a set of
names of slots accessible in that instance, and any number of initialization
arguments. The arguments after the first two must form an initialization
argument list. The system-supplied primary method on {\bf
shared-initialize} initializes the slots with values according to the
initialization arguments and specified {\bf :initform} forms. The
second argument indicates which slots should be initialized according
to their {\bf :initform} forms if no initialization arguments are
provided for those slots.
The system-supplied primary method behaves as follows, regardless of
whether the slots are local or shared:
\beginlist
\item{\bull} If an initialization argument in the
initialization argument list specifies a value for that slot, that
value is stored into the slot, even if a value has
already been stored in the slot before the method is run.
\item{\bull} Any slots indicated by the second argument that are still
unbound at this point are initialized according to their {\bf
:initform} forms. For any such slot that has an {\bf :initform} form,
that form is evaluated in the lexical environment of its defining {\bf
defclass} form and the result is stored into the slot. For example, if
a {\bf :before} method stores a value in the slot, the {\bf :initform}
form will not be used to supply a value for the slot.
\item{\bull} The rules mentioned in the section ``Rules for
Initialization Arguments'' are obeyed.
\endlist
\label Syntax:
\Defgen {shared-initialize} {instance slot-names {\tt \&rest {\it initargs}}}
\label Method Signatures:
\Defmeth {shared-initialize} {({\it instance\/} standard-object) {\it
slot-names\/} {\rest} {\it initargs}}
\label Arguments:
The {\it instance\/} argument is the object to be initialized.
The {\it slots-names\/} argument specifies the slots that are to be
initialized according to their {\bf :initform} forms if no
initialization arguments apply. It is supplied in one of three forms
as follows:
\beginlist
\item{\bull} It can be list of slot names, which specifies
the set of those slot names.
\item{\bull} It can be {\bf nil}, which specifies the empty set of
slot names.
\item{\bull} It can be the symbol {\bf t}, which specifies the set of
all of the slots.
\endlist
The {\it initargs\/} argument consists of alternating initialization
argument names and values.
\label Values:
The modified instance is returned as the result.
\label Remarks:
Initialization arguments are declared as valid by using the {\bf
:initarg} option to {\bf defclass}, or by defining methods for {\bf
shared-initialize}. The keyword name of each keyword parameter
specifier in the lambda-list of any method defined on {\bf
shared-initialize} is declared as a valid initialization argument
name for all classes for which that method is applicable.
Implementations are permitted to optimize {\bf :initform} forms that
neither produce nor depend on side effects, by evaluating these forms
and storing them into slots before running any {\bf
initialize-instance} methods, rather than by handling them in the
primary {\bf initialize-instance} method. (This optimization might
be implemented by having the {\bf allocate-instance} method copy a
prototype instance.)
Implementations are permitted to optimize default initial value forms
for initialization arguments associated with slots by not actually
creating the complete initialization argument list when the only method
that would receive the complete list is the method on {\bf
standard-object}. In this case default initial value forms can be
treated like {\bf :initform} forms. This optimization has no visible
effects other than a performance improvement.
\label See Also:
``Object Creation and Initialization''
``Rules for Initialization Arguments''
``Declaring the Validity of Initialization Arguments''
{\bf initialize-instance
reinitialize-instance
update-instance-for-redefined-class
update-instance-for-different-class
slot-boundp
slot-makunbound}
\endcom
\begincom{slot-boundp}\ftype{Function}
\label Purpose:
The function {\bf slot-boundp} tests whether a specific slot in an
instance is bound.
\label Syntax:
\Defun {slot-boundp} {instance slot-name}
\label Arguments:
The arguments are the instance and the name of the slot.
\label Values:
The function {\bf slot-boundp} returns true or false.
\label Remarks:
The function {\bf slot-boundp} allows for writing {\bf :after}
methods on {\bf initialize-instance} in order to initialize only
those slots that have not already been bound.
If no slot of the given name exists in the instance, {\bf slot-missing}
is called as follows:\hfil\break
{\tt (slot-missing (class-of {\it instance\/})
{\it instance slot-name\/} 'slot-boundp)}
The function {\bf slot-boundp} is implemented using {\bf
slot-boundp-using-class}.
\label See Also:
{\bf slot-missing}
\endcom
\begincom{slot-exists-p}\ftype{Function}
\label Purpose:
The function {\bf slot-exists-p} tests whether the specified object has
a slot of the given name.
\label Syntax:
\Defun {slot-exists-p} {object slot-name}
\label Arguments:
The {\it object\/} argument is any object. The {\it slot-name\/} argument
is a symbol.
\label Values:
The function {\bf slot-exists-p} returns true or false.
\label Remarks:
The function {\bf slot-exists-p} is implemented using {\bf
slot-exists-p-using-class}.
\endcom
\begincom{slot-makunbound}\ftype{Function}
\label Purpose:
The function {\bf slot-makunbound} restores a slot in an instance to
the unbound state.
\label Syntax:
\Defun {slot-makunbound} {instance slot-name}
\label Arguments:
The arguments to {\bf slot-makunbound} are the instance and the name of
the slot.
\label Values:
The instance is returned as the result.
\label Remarks:
If no slot of the given name exists in the instance, {\bf slot-missing}
is called as follows:\hfil\break
{\tt (slot-missing (class-of {\it instance\/})
{\it instance slot-name\/} 'slot-makunbound)}
The function {\bf slot-makunbound} is implemented using {\bf
slot-makunbound-using-class}.
\label See Also:
{\bf slot-missing}
\endcom
\begincom{slot-missing}\ftype{Standard Generic Function}
\label Purpose:
The generic function {\bf slot-missing} is invoked when an attempt is
made to access a slot in an object whose metaclass is {\bf
standard-class} and the name of the slot provided is not a name of a
slot in that class.
The default method signals an error.
The generic function {\bf slot-missing} is not intended to be called by
programmers. Programmers may write methods for it.
\label Syntax:
\Defgen {slot-missing} {class object slot-name operation {\opt} new-value}
\label Method Signatures:
\Defmeth {slot-missing} {\vtop{\hbox{({\it class\/} t) {\it object slot-name}}
\hbox{{\it operation\/} {\opt} {\it new-value}}}}
\label Arguments:
The required arguments to {\bf slot-missing} are the class of the object
that is being accessed, the object, the slot name, and a symbol that
indicates the operation that caused {\bf slot-missing} to be invoked.
The optional argument to {\bf slot-missing} is used when the operation
is attempting to set the value of the slot.
\label Values:
If a method written for {\bf slot-missing} returns values, these
values get returned as the values of the original function invocation.
\label Remarks:
The generic function {\bf slot-missing} may be called during
evaluation of {\bf slot-value}, {\bf (setf slot-value)},
{\bf slot-boundp}, and {\bf slot-makunbound}. For each
of these operations the corresponding symbol for the {\it operation\/}
argument is {\bf slot-value}, {\bf setf}, {\bf slot-boundp}, and {\bf
slot-makunbound} respectively.
The set of arguments (including the class of the instance) facilitates
defining methods on the metaclass for {\bf slot-missing}.
\endcom
\begincom{slot-unbound}\ftype{Standard Generic Function}
\label Purpose:
The generic function {\bf slot-unbound} is called when an
unbound slot is read in an instance whose metaclass is {\bf
standard-class}.
The default method signals an error.
The generic function {\bf slot-unbound} is not intended to be called
by programmers. Programmers may write methods for it.
The function {\bf slot-unbound} is called only by the function
{\bf slot-value-using-class} and thus indirectly by {\bf slot-value}.
\label Syntax:
\Defgen {slot-unbound} {class instance slot-name}
\label Method Signatures:
\Defmeth {slot-unbound} {({\it class\/} t) {\it instance slot-name}}
\label Arguments:
The arguments to {\bf slot-unbound} are the class of the instance
whose slot was accessed, the instance itself, and the name of the
slot.
\label Values:
If a method written for {\bf slot-unbound} returns values, these
values get returned as the values of the original function invocation.
\label Remarks:
An unbound slot may occur if no {\bf :initform} form was
specified for the slot and the slot value has not been set, or if {\bf
slot-makunbound} has been called on the slot.
\label See Also:
{\bf slot-makunbound}
\endcom
\begincom{slot-value}\ftype{Function}
\label Purpose:
The function {\bf slot-value} returns the value contained in the slot
{\it slot-name\/} of the given object. If there is no slot with that
name, {\bf slot-missing} is called. If the slot is unbound,
{\bf slot-unbound} is called.
The macro {\bf setf} can be used with {\bf slot-value} to change the value
of a slot.
\label Syntax:
\Defun {slot-value} {object slot-name}
\label Arguments:
The arguments are the object and the name of the given slot.
\label Values:
The result is the value contained in the given slot.
\label Remarks:
If an attempt is made to read a slot and no slot of the given name
exists in the instance, {\bf slot-missing} is called as follows: {\tt
(slot-missing (class-of {\it instance\/}) {\it instance slot-name\/}
'slot-value)}
If an attempt is made to write a slot and no slot of the given name
exists in the instance, {\bf slot-missing} is called as follows: {\tt
(slot-missing (class-of {\it instance\/}) {\it instance slot-name\/}
'setf {\it new-value\/})}
The function {\bf slot-value} is implemented using {\bf
slot-value-using-class}.
Implementations may optimize {\bf slot-value} by compiling it inline.
\label See Also:
{\bf slot-missing}
{\bf slot-unbound}
\endcom
\begincom{symbol-macrolet}\ftype{Macro}
\label Purpose:
The macro {\bf symbol-macrolet} provides a mechanism for the
substitution of forms for variable names within a lexical scope.
\label Syntax:
\Defmac {symbol-macrolet} {\paren{\star{\paren{symbol expansion\/}}} {\body} {\it body\/}}
\label Arguments:
The {\it symbol\/} argument specifies the symbol with which the form specified
by the {\it expansion\/} argument is to be associated.
\label Values:
The result returned is that obtained by executing the forms specified
by the {\it body\/} argument.
\label Examples:
\screen!
(symbol-macrolet ((x 'foo))
(list x (let ((x 'bar)) x)))
;;; The result is (foo bar), not (foo foo).
;;; The expansion is (list 'foo (let ((x 'bar)) x)),
;;; not (list 'foo (let (('foo 'bar)) 'foo)).
(symbol-macrolet ((x (1+ x)))
(print x))
;;; The expansion is (print (1+ x)),
;;; not (print (1+ (1+ (1+ ....
\endscreen!
\label Remarks:
The lexical scope of {\bf symbol-macrolet} is {\it body\/}; it does
not include {\it expansion}.
Each reference to {\it symbol\/} as a variable within the lexical scope
of {\bf symbol-macrolet} is replaced by {\it expansion\/} (not the
result of evaluating {\it expansion\/}).
The use of {\bf symbol-macrolet} can be shadowed by {\bf let}.
In other words, {\bf symbol-macrolet} only substitutes for occurrences
of {\it symbol\/} that would be in the scope of a lexical binding of
{\it symbol\/} surrounding the body.
The macro {\bf symbol-macrolet} is the basic mechanism that is used to
implement {\bf with-slots}.
When the body of the {\bf symbol-macrolet} form is expanded, any use of
{\bf setq} to set the value of one of the specified variables is
converted to a use of {\bf setf}.
\label See Also:
{\bf with-slots}
\endcom
\begincom{update-instance-for-different-class}\ftype{Standard Generic Function}
\label Purpose:
The generic function {\bf update-instance-for-different-class} is not
intended to be called by programmers. Programmers may write
methods for it. The function {\bf update-instance-for-different-class}
is called only by the function {\bf change-class}.
%End Part 7 of 8 functi.tex